
template<class S>
    class MyHash {
        private:
        int MAX_HAS_LEN;
        map<S,int> mp;
        S *points;
        int nPoints;
        int ID;
        public:
        MyHash ( int size ) {
            this->MAX_HAS_LEN=size;
            points = new S[size];
            ID=1;
            mp.clear();
            nPoints=0;
        }
        ~MyHash() {
            delete[] points;
        }
        inline void Push ( S point ) {
            points[nPoints]=point;
            ++nPoints;
        }
        inline void Encode() {
            sort ( points,points+nPoints,less<S>() );
            S prv;
            bool prothom=true;
            for ( int i=0; i<nPoints; ++i ) {
                if ( prothom ) {
                    prothom=false;
                    prv=points[i];
                    mp[ points[i] ]=ID;
                    ++ID;
                } else {
                    if ( prv!=points[i] ) {
                        prv=points[i];

                        mp[ points[i] ]=ID;
                        ++ID;
                    }
                }
            }
        }
        inline int GetId ( S point ) {
            return mp[point];
        }
        inline int PointCounts() {
            return ID;
        }

    };
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; 

